package com.ruoyi.system.controller.backend;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.controller.CxBase;
import com.ruoyi.system.domain.CaseInfo;
import com.ruoyi.system.domain.backend.CaseBack;
import com.ruoyi.system.domain.backend.CaseBackDeployment;
import com.ruoyi.system.domain.backend.CaseBackStatus;
import com.ruoyi.system.domain.front.CaseInfoInsertFront;
import com.ruoyi.system.service.ICaseInfoService;
import com.ruoyi.system.service.backend.ICaseBackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

/**
 * 案件信息Controller
 *
 * @author ruoyi
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/system/back/caseback")
public class CaseBackController extends CxBase {
    @Autowired
    private ICaseBackService caseBackService;
    @Autowired
    private ICaseInfoService caseInfoService;


    /**
     * 查询报警列表
     */
    @PreAuthorize("@ss.hasPermi('system:alarmhistory:list')")
    @GetMapping("/selectcaseback")
    public TableDataInfo selectcaseback(CaseBack caseBack)
    {
        logput(caseBack,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(caseBackService.selectcaseback(caseBack));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }
    /**
     * 查询报警详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:alarmhistory:query')")
    @GetMapping("/selectcasebackInfo")
    public TableDataInfo selectcasebackInfo(CaseBack caseBack)
    {
        logput(caseBack,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(caseBackService.selectcasebackInfo(caseBack));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }

    /**
     * 报警状态更新
     */
    @PreAuthorize("@ss.hasPermi('system:alarmhistory:edit')")
    @Transactional
    @Log(title = "报警状态更新", businessType = BusinessType.UPDATE)
    @PostMapping("/updateCaseBackStatus")
    public AjaxResult updateCaseBackStatus(@RequestBody CaseBackStatus caseBackStatus)
    {
        logput(caseBackStatus,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return toAjax(caseBackService.updateCaseBackStatus(caseBackStatus));
    }

    /**
     * 调配处理
     */
    @PreAuthorize("@ss.hasPermi('system:alarmhistory:deployment')")
    @Transactional
    @Log(title = "调配处理", businessType = BusinessType.UPDATE)
    @PostMapping("/updatedeployment")
    public AjaxResult updatedeployment(@RequestBody CaseBackDeployment caseBackDeployment)
    {
        logput(caseBackDeployment,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return toAjax(caseBackService.updateCaseBackDeployment(caseBackDeployment));
    }

    /**
     * 回访操作
     */
    @PreAuthorize("@ss.hasPermi('system:alarmhistory:revisited')")
    @Transactional
    @Log(title = "回访操作", businessType = BusinessType.UPDATE)
    @PostMapping("/updateCaseReturnVisit")
    public AjaxResult updateCaseReturnVisit(@RequestBody CaseInfo caseInfo)
    {
        logput(caseInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return toAjax(caseBackService.updateCaseReturnVisit(caseInfo));
    }

    /**
     * 输入案件警方备案号
     */
    @PreAuthorize("@ss.hasPermi('system:alarmhistory:entercaseid')")
    @Transactional
    @Log(title = "输入案件警方备案号", businessType = BusinessType.UPDATE)
    @PostMapping("/updatePoliceCaseId")
    public AjaxResult updatePoliceCaseId(@RequestBody CaseInfo caseInfo)
    {
        logput(caseInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return toAjax(caseInfoService.updateCaseInfo(caseInfo));
    }

    /**
     * 查询封面统计信息
     */
    @GetMapping("/selectcaseInfoback")
    public TableDataInfo selectcaseInfoback(CaseBack caseBack) throws ParseException {
        logput(caseBack,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(caseBackService.selectcaseInfoback(caseBack));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }
}
